{extend name="public/base" /}

{block name="title"}<title>{$Think.lang.list}</title>{/block}

{block name="pjax_container"}
<section class="content-header">
    <h1>文章列表</h1>
    <ol class="breadcrumb">
        <li class="active"><i class="fa fa-dashboard"></i> 文章列表</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title"></h3>
                    <div class="pull-left">
                        {:authAction(CONTROLLER_NAME.'/delete', 'delete_all')} 
                    </div>
                    {include file="public/search" /}
                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover table-sort">
                        <tr>
                            <th width="35"><input type="checkbox" class="minimal checkbox-toggle"></th>
                            <th>{$Think.lang.id}{:table_sort('id')}</th>
                            <th>{$Think.lang.title}{:table_sort('title')}</th>
                            <th>{$Think.lang.typeid}</th>
                            <th>{$Think.lang.writer}/{$Think.lang.id}</th>
                            <th>{$Think.lang.click}{:table_sort('click')}</th>
                            <th>{$Think.lang.create_time}</th>
                            <th>{$Think.lang.status}{:table_sort('status')}</th>
                            <th width="178">{$Think.lang.action}</th>
                        </tr>
                        {volist name="dataList" id="vo"}
                        <tr>
                            <td><input type="checkbox" name="id[]" value="{$vo.id}" class="minimal"></td>
                            <td>{$vo.id}</td>
                            <td>
                                <span class="editable" data-pk="{$vo.id}" data-name="title" data-url="{:url(CONTROLLER_NAME.'/edit', 'id='.$vo['id'])}" >{$vo.title}</span>
                                {foreach $vo.flag as $vo2}
                                {if condition=" $vo2 eq 'c' "}<span class="label label-info">{$Think.lang.flag_c}</span>
                                {elseif condition=" $vo2 eq 'a' "/}<span class="label label-info">{$Think.lang.flag_a}</span>
                                {elseif condition=" $vo2 eq 'h' "/}<span class="label label-info">{$Think.lang.flag_h}</span>
                                {elseif condition=" $vo2 eq 's' "/}<span class="label label-info">{$Think.lang.flag_s}</span>
                                {elseif condition=" $vo2 eq 'p' "/}<span class="label label-info">{$Think.lang.flag_p}</span>
                                {elseif condition=" $vo2 eq 'j' "/}<span class="label label-info">{$Think.lang.flag_j}</span>
                                {/if}
                                {/foreach}
                            </td>
                            <td>
                                {if condition=" !empty($vo.Arctype->typename) "}
                                {$vo.Arctype->typename}
                                {else /}
                                {$Think.lang.no_arctype}
                                {/if}
                            </td>
                            <td>{$vo.User->name}/{$vo.writer}</td>
                            <td>{$vo.click}</td>
                            <td>{$vo.create_time}</td>
                            <td>
                                <a href="javascript:void(0);" data-id="{$vo.id}" data-field="status" 
                                data-value="{$vo.status}" data-url="{:url('edit', 'id='.$vo['id'])}" 
                                class='editimg fa {if condition=" $vo.status == 1 "}fa-check-circle text-green{else /}fa-times-circle text-red{/if}'></a>
                            </td>
                            <td>
                                {if condition=" !empty($vo.arcurl) "}
                                <a class="btn btn-primary btn-xs" href="{$vo.arcurl}" target="_blank"><i class="fa fa-eye"></i> {$Think.lang.preview}</a>
                                {else /}
                                <button class="btn btn-default btn-xs disabled"><i class="fa fa-edit"></i> {$Think.lang.preview}</button>
                                {/if}
                                {include file="public/list_action" /}
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <div class="box-footer clearfix">
                    {$dataList->render()}
                </div>
            </div>
        </div>
    </div>
</section>
<script type="text/javascript">
$(function(){
    /*ajax页面加载icheck，有该控件的页面才需要*/
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
        checkboxClass: 'icheckbox_minimal-blue',
        radioClass: 'iradio_minimal-blue'
    });
    
    /*ajax页面加载icheck，有该控件的页面才需要*/
    $(".select2").select2({language:"zh-CN"});
    
    /*全选-反选*/
    $('.checkbox-toggle').on('ifChecked', function(event){
        var _this = $(this);
        var _table = _this.closest('.table');
        _table.find("tr td input[type='checkbox']").iCheck("check");
    });
    $('.checkbox-toggle').on('ifUnchecked', function(event){
        var _this = $(this);
        var _table = _this.closest('.table');
        _table.find("tr td input[type='checkbox']").iCheck("uncheck");
    });
    
    $('.editable').editable({
        emptytext: "empty",
        params: function(params) {      //参数
            var data = {};
            data['id'] = params.pk;
            data[params.name] = params.value;
            return data;
        },
        success: function(response, newValue) {
            var res = $.parseJSON( response );
            if(res.status == 1){
            }else{
                return res.info;
            }
        }
    });
    
    {if condition=" $rest_login == 1 "}
    restlogin('{$rest_login_info}');   //登录超时
    {/if}
})
</script>
{/block}